﻿

@model PagedList<WaitJiesuanModel>
@{
    ViewBag.Title = "供应商待结算列表";
    Layout = "~/Views/Shared/_ContentLayout.cshtml";

    WaitJiesuanQueryModel paramModel = new WaitJiesuanQueryModel();
    if (ViewBag.paramModel != null)
    {
        paramModel = (WaitJiesuanQueryModel)ViewBag.paramModel;
    }
    ADZ_MasterEntities dbcontext = new ADZ_MasterEntities();
    Dictionary<string, string> dc = new Dictionary<string, string>();

}
<form id="S_Form" class="form-inline definewidth m20" action="@Url.Action("WaitList", "Jiesuan")" method="get">
    <div class="form_query">
        <div>
            供应商：
            <input type="text" name="supplier_name" id="supplier_name" class="abc input-default" placeholder="" value="@paramModel.supplier_name">&nbsp;
        </div>
        <div>
            订单号：
            <input type="text" name="order_no" id="order_no" class="abc input-default" placeholder="" value="@paramModel.order_no">&nbsp;
        </div>
        <div>
            结算状态：
            <select id="jiesuan_status" name="jiesuan_status">
                <option value="-10" @(paramModel.jiesuan_status == -10 ? "selected" : "")>全部</option>
                @{
                    dc = new Dictionary<string, string>();
                    MyEnumHelper.GetEnumItems(typeof(jiesuan_status)).ForEach(t =>
                    {
                        dc.Add(t.Value.ToString(), t.Description);
                    });
                }
                @HtmlPagerHelper.ShowSelectOpton(dc, paramModel.jiesuan_status.ToString());
            </select>&nbsp;
        </div>
        <div>
            @{Html.RenderPartial(Url.Content("~/Views/Common/PageSize.cshtml"), paramModel);}
        </div><div>
            <button type="submit" class="btn btn-primary" id="formsubmit">查询</button>
            <button type="button" class="btn btn-primary" id="dojiesuan">发起结算</button>
        </div>
    </div>
</form>
<form id="Jiesuan_Form" class="form-inline definewidth m20" action="@Url.Action("applyjiesuan", "Jiesuan")" method="get">
    <table class="table table-bordered table-hover definewidth m10">
        <thead>
            <tr>
                <th style="width:40px"><input type="checkbox" name="chkall" id="chkall" />全选</th>
                <th>收款方名称</th>
                <th>订单号</th>
                <th>订单日期</th>
                <th>付款类型</th>
                <th>付款货币</th>
                <th>是否含税</th>
                <th>付款渠道</th>
                <th>订单金额</th>
                <th>供货金额</th>
                <th>执行状态</th>
                <th>付款申请人</th>
                <th>备注</th>
                <th>申请时间</th>
                <th>驳回理由</th>
            </tr>
        </thead>
        @if (Model != null && Model.Count != 0)
        {
            int index = 0;
            foreach (var m in Model)
            {
                index++;
        <tr class="@HtmlPagerHelper.TrClass(index)">
            <td>
                <input type="checkbox" name="cbx_last" value="@m.aDZ_JiesuanOrderDetails.seq_id" />
            </td>
            <td>@m.aDZ_SupplierMaster.supplier_name</td>
            <td>@m.aDZ_JiesuanOrderDetails.order_no</td>
            <td>@m.aDZ_JiesuanOrderDetails.order_time.ToString(2)</td>
            <td>货款（向供应商结算）</td>
            <td>
                @(MyEnumHelper.GetEnumItemDescription<CurrencyType>(m.aDZ_JiesuanOrderDetails.currency_type))
            </td>
            <td> @(MyEnumHelper.GetEnumItemDescription<include_tax>(m.aDZ_JiesuanOrderDetails.include_tax))</td>
            <td> @(MyEnumHelper.GetEnumItemDescription<SupplierPayChanner>(m.aDZ_JiesuanMaster.channel))</td>
            <td>@m.aDZ_JiesuanOrderDetails.order_money.ToString("N2")</td>
            <td>@m.aDZ_JiesuanOrderDetails.supply_money.ToString("N2")</td>
            <td>
                @(MyEnumHelper.GetEnumItemDescription<jiesuan_status>(m.aDZ_JiesuanOrderDetails.jiesuan_status))
            </td>
            <td>
                @m.aDZ_JiesuanOrderDetails.apply_username
            </td>
            <td>
                @m.aDZ_JiesuanMaster.remark
            </td>
            <td>
                @m.aDZ_JiesuanOrderDetails.apply_time.ToString(1)
            </td>
            <td>
                @m.aDZ_JiesuanMaster.reject_reson
            </td>
        </tr>
            }
            <tr>
                <td colspan="20"></td>
            </tr>
        }
    </table>
    <div class="inline pull-left total">
        总行数：@ViewData["AllCount"] | 总订单金额：@string.Format("{0:N2}", ViewData["order_money"])
    </div>
    <div class="inline pull-right page">
        @if (Model != null)
        {
            @Html.Pager(Model, HtmlPagerHelper.BasePagerOption)
        }
    </div>
</form>
<script>
    var cancelButton =
        {
            text: '取消',
            elCls: 'button',
            handler: function () {
                this.close();
            }
        };
    reloadHandler = function ()
    {
        window.location.reload();
    }
    
    $("#dojiesuan").click(function () {
        var ids = getCheckboxList();
        if (ids.length == 0) {
            BUI.Message.Alert("请选择要结算的数据", 'warning');
            return;
        }
        BUI.Message.Show({
            title: '提示',
            msg: '确定要申请结算吗?',
            icon: 'question',
            buttons: [
              {
                  text: '确定',
                  elCls: 'button button-primary',
                  handler: function () {
                      url = "@Url.Action("applyjiesuan", "jiesuan")";
                      parameter = { ids: ids };
                      $.post(url, parameter, function (result) {
                          ShowActionResult(result, reloadHandler);
                      });
                      this.close();
                  }
                },
                cancelButton
            ]
        });
    });
</script>
